package com.examination.client.util;

import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;

public class IdCardUtil {
    public static void main(String[] args) {
        test("贾永辉", "13013019941219");
    }
    /*
     * 校验身份证实名信息
     */
    public static Map test(String name,String idCard) {
        String host = "https://idcert.market.alicloudapi.com";
        String path = "/idcard";
        String method = "GET";
        String appcode = "569409ef081849b7ba2b5d2b8b096772";
        Map<String, String> headers = new HashMap<String, String>();

        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<String, String>();

        querys.put("name", name);
        querys.put("idCard", idCard);
        try {
            HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
            Map map = (Map)JSONObject.parse(EntityUtils.toString(response.getEntity()));
            return map;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

